<%--
  Created by IntelliJ IDEA.
  User: yuzhou
  Date: 2017/9/30
  Time: 下午3:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="common/tag.jsp"%>
<html>
<head>
  <title>View Cart</title>
</head>
<body>
  <h1>View Cart</h1>
  <h2>Items in Your Cart </h2>
  <c:choose>
    <c:when test="${empty cart.items}">
      <p> Your cart is empty </p>
    </c:when>
    <c:otherwise>
      <p> cart item list</p>
      <table border="1" cellspacing="0">
        <tr>
          <th>Item</th>
          <th>Quantity</th>
          <th>Unit Price</th>
          <th>Total</th>
        </tr>

        <c:forEach var="item" items="${cart.items}">
          <tr>
            <td>${item.product.description}</td>
            <td>${item.quantity}</td>
            <td>${item.product.price}</td>
            <td>${item.totalPrice}</td>
          </tr>
        </c:forEach>

        <tr>
          <td>TOTAL:</td>
          <td></td>
          <td></td>
          <td>${cart.totalPrice}</td>
        </tr>
      </table>
    </c:otherwise>
  </c:choose>
  <a href="${flowExecutionUrl}&_eventId=submit">submit</a>
  <a href="${flowExecutionUrl}&_eventId=cancelShopping">cancel shopping</a>

  <h2>Products for Your Choice</h2>
  <table>
    <c:forEach var="product" items="${products}">
      <tr>
        <td>${product.id}</td>
        <td>${product.description}</td>
        <td>${product.price}</td>
        <td>
          <a href="${flowExecutionUrl}&_eventId=addToCart&productId=${product.id}">[add to cart]</a>
        </td>
      </tr>
    </c:forEach>
  </table>
</body>
</html>
